{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "573cca9e",
   "metadata": {},
   "source": [
    "-------------------------------------\n",
    "· 日期：2022-09-14\\week04(周三)\n",
    "\n",
    "· 课程：python\n",
    "\n",
    "· 记录人：林荣烽"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3378bc2c",
   "metadata": {},
   "source": [
    "# 回顾与复习\n",
    "\n",
    "    for+range()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5fd29e42",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b3c35d34",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(0, 5)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建有序数值（创建自然数）\n",
    "range(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "96cd9a98",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(0,5))  # 产生了 5-0 个值 ，默认从0开始    注：0（start） 5（stop）  每一次增长 1 个单位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "b8f0a2b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(2, 5)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(2,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "26ce277d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, 3, 4]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(2,5)) # 产生了 5-2 个值 ， start = 2   stop = 5  每一次增长 1 个单位（step）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "21b2e602",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(1, 10, 3)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(1,10,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "1df8c34f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 7]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(1,10,3)) # start = 2  stop = 5  每一次增长 3 个单位 step = 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "1e802106",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/xxyw/index0.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index1.htm\n",
      "该次停留 7 秒\n",
      "https://www.nfu.edu.cn/xxyw/index2.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index3.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index4.htm\n",
      "该次停留 7 秒\n"
     ]
    }
   ],
   "source": [
    "### 实战练习：快速生成 某个网站的所有页码的URL队列\n",
    "import random\n",
    "import time\n",
    "南方学院学校要闻 = \"https://www.nfu.edu.cn/xxyw/index\"\n",
    "页面后缀 = \".htm\"\n",
    "page = 5\n",
    "\n",
    "for i in range(page):\n",
    "    print(南方学院学校要闻 + str(i) + 页面后缀)  # 字符串拼接\n",
    "    random_num = random.randint(1,10)\n",
    "    print(\"该次停留\",random_num,'秒')\n",
    "    time.sleep(random_num)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9082185f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 总结，for+range    for可以执行循环 ， range决定了循环体的执行次数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e288db5b",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "\n",
    "> 1. random模块\n",
    ">> 1. random.random():生成0-1之间的 伪随机数（浮点型数）\n",
    ">> 1. random.randint(a,b):生成a-b之间的 随机整数（整数）\n",
    ">> 1. random.choice():随机生成一个序列中的值（非空）\n",
    "> 2. time模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40c62067",
   "metadata": {},
   "source": [
    "# 1.random模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "09e0dd85",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 1. random\n",
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "59238236",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.938488208606156"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "92dd3e74",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function random:\n",
      "\n",
      "random() method of random.Random instance\n",
      "    random() -> x in the interval [0, 1).\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.random)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "e1b73f7a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method randint in module random:\n",
      "\n",
      "randint(a, b) method of random.Random instance\n",
      "    Return random integer in range [a, b], including both end points.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "## 2. randint\n",
    "help(random.randint)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "4f4ae9e6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(1,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "92ce670a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "6\n",
      "3\n",
      "4\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(random.randint(1,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "033c2fc4",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 3. random.choice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "8e2cfbe1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method choice in module random:\n",
      "\n",
      "choice(seq) method of random.Random instance\n",
      "    Choose a random element from a non-empty sequence.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.choice)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "3dea3be2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'赖文佩'"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.choice(['黄柏睿','李圣卿','李圆圆','赖文佩','赖文佩','赖文佩'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "186cd6b3",
   "metadata": {},
   "source": [
    "# 2.time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "02f8fca0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "60763102",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sleep in module time:\n",
      "\n",
      "sleep(...)\n",
      "    sleep(seconds)\n",
      "    \n",
      "    Delay execution for a given number of seconds.  The argument may be\n",
      "    a floating point number for subsecond precision.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time.sleep)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "28919e02",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n",
      "world\n"
     ]
    }
   ],
   "source": [
    "print(\"hello\")\n",
    "time.sleep(3)\n",
    "print(\"world\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e03d5c3b",
   "metadata": {},
   "source": [
    "# 3.课本实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e38bdaec",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 项目2 P35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "10a352e6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "52\n",
      "现在秒/时间为偶数\n",
      "等待时间为: 4\n",
      "56\n",
      "现在秒/时间为偶数\n",
      "等待时间为: 1\n",
      "57\n",
      "现在是秒/时间为奇数\n",
      "等待时间为: 1\n",
      "58\n",
      "现在秒/时间为偶数\n",
      "等待时间为: 3\n",
      "1\n",
      "现在是秒/时间为奇数\n",
      "等待时间为: 5\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "import time,random\n",
    "\n",
    "odds = [  1, 3, 5, 7, 9, 11, 13, 15, 17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "\n",
    "for i in range(5):\n",
    "    right_this_second = datetime.datetime.today().second\n",
    "    if right_this_second in odds:\n",
    "        print(right_this_second)\n",
    "        print(\"现在是秒/时间为奇数\")\n",
    "    else:\n",
    "        print(right_this_second)\n",
    "        print(\"现在秒/时间为偶数\")\n",
    "    wait_time = random.randint(1,5)\n",
    "    print(\"等待时间为:\",wait_time)\n",
    "    time.sleep(wait_time)\n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "cb65fac6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles 在啤酒墙上~~\n",
      "99 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "98 bottles 在啤酒墙上\n",
      "\n",
      "98 bottles 在啤酒墙上~~\n",
      "98 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "97 bottles 在啤酒墙上\n",
      "\n",
      "97 bottles 在啤酒墙上~~\n",
      "97 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "96 bottles 在啤酒墙上\n",
      "\n",
      "96 bottles 在啤酒墙上~~\n",
      "96 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "95 bottles 在啤酒墙上\n",
      "\n",
      "95 bottles 在啤酒墙上~~\n",
      "95 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "94 bottles 在啤酒墙上\n",
      "\n",
      "94 bottles 在啤酒墙上~~\n",
      "94 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "93 bottles 在啤酒墙上\n",
      "\n",
      "93 bottles 在啤酒墙上~~\n",
      "93 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "92 bottles 在啤酒墙上\n",
      "\n",
      "92 bottles 在啤酒墙上~~\n",
      "92 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "91 bottles 在啤酒墙上\n",
      "\n",
      "91 bottles 在啤酒墙上~~\n",
      "91 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "90 bottles 在啤酒墙上\n",
      "\n",
      "90 bottles 在啤酒墙上~~\n",
      "90 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "89 bottles 在啤酒墙上\n",
      "\n",
      "89 bottles 在啤酒墙上~~\n",
      "89 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "88 bottles 在啤酒墙上\n",
      "\n",
      "88 bottles 在啤酒墙上~~\n",
      "88 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "87 bottles 在啤酒墙上\n",
      "\n",
      "87 bottles 在啤酒墙上~~\n",
      "87 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "86 bottles 在啤酒墙上\n",
      "\n",
      "86 bottles 在啤酒墙上~~\n",
      "86 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "85 bottles 在啤酒墙上\n",
      "\n",
      "85 bottles 在啤酒墙上~~\n",
      "85 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "84 bottles 在啤酒墙上\n",
      "\n",
      "84 bottles 在啤酒墙上~~\n",
      "84 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "83 bottles 在啤酒墙上\n",
      "\n",
      "83 bottles 在啤酒墙上~~\n",
      "83 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "82 bottles 在啤酒墙上\n",
      "\n",
      "82 bottles 在啤酒墙上~~\n",
      "82 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "81 bottles 在啤酒墙上\n",
      "\n",
      "81 bottles 在啤酒墙上~~\n",
      "81 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "80 bottles 在啤酒墙上\n",
      "\n",
      "80 bottles 在啤酒墙上~~\n",
      "80 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "79 bottles 在啤酒墙上\n",
      "\n",
      "79 bottles 在啤酒墙上~~\n",
      "79 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "78 bottles 在啤酒墙上\n",
      "\n",
      "78 bottles 在啤酒墙上~~\n",
      "78 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "77 bottles 在啤酒墙上\n",
      "\n",
      "77 bottles 在啤酒墙上~~\n",
      "77 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "76 bottles 在啤酒墙上\n",
      "\n",
      "76 bottles 在啤酒墙上~~\n",
      "76 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "75 bottles 在啤酒墙上\n",
      "\n",
      "75 bottles 在啤酒墙上~~\n",
      "75 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "74 bottles 在啤酒墙上\n",
      "\n",
      "74 bottles 在啤酒墙上~~\n",
      "74 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "73 bottles 在啤酒墙上\n",
      "\n",
      "73 bottles 在啤酒墙上~~\n",
      "73 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "72 bottles 在啤酒墙上\n",
      "\n",
      "72 bottles 在啤酒墙上~~\n",
      "72 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "71 bottles 在啤酒墙上\n",
      "\n",
      "71 bottles 在啤酒墙上~~\n",
      "71 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "70 bottles 在啤酒墙上\n",
      "\n",
      "70 bottles 在啤酒墙上~~\n",
      "70 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "69 bottles 在啤酒墙上\n",
      "\n",
      "69 bottles 在啤酒墙上~~\n",
      "69 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "68 bottles 在啤酒墙上\n",
      "\n",
      "68 bottles 在啤酒墙上~~\n",
      "68 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "67 bottles 在啤酒墙上\n",
      "\n",
      "67 bottles 在啤酒墙上~~\n",
      "67 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "66 bottles 在啤酒墙上\n",
      "\n",
      "66 bottles 在啤酒墙上~~\n",
      "66 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "65 bottles 在啤酒墙上\n",
      "\n",
      "65 bottles 在啤酒墙上~~\n",
      "65 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "64 bottles 在啤酒墙上\n",
      "\n",
      "64 bottles 在啤酒墙上~~\n",
      "64 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "63 bottles 在啤酒墙上\n",
      "\n",
      "63 bottles 在啤酒墙上~~\n",
      "63 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "62 bottles 在啤酒墙上\n",
      "\n",
      "62 bottles 在啤酒墙上~~\n",
      "62 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "61 bottles 在啤酒墙上\n",
      "\n",
      "61 bottles 在啤酒墙上~~\n",
      "61 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "60 bottles 在啤酒墙上\n",
      "\n",
      "60 bottles 在啤酒墙上~~\n",
      "60 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "59 bottles 在啤酒墙上\n",
      "\n",
      "59 bottles 在啤酒墙上~~\n",
      "59 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "58 bottles 在啤酒墙上\n",
      "\n",
      "58 bottles 在啤酒墙上~~\n",
      "58 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "57 bottles 在啤酒墙上\n",
      "\n",
      "57 bottles 在啤酒墙上~~\n",
      "57 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "56 bottles 在啤酒墙上\n",
      "\n",
      "56 bottles 在啤酒墙上~~\n",
      "56 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "55 bottles 在啤酒墙上\n",
      "\n",
      "55 bottles 在啤酒墙上~~\n",
      "55 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "54 bottles 在啤酒墙上\n",
      "\n",
      "54 bottles 在啤酒墙上~~\n",
      "54 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "53 bottles 在啤酒墙上\n",
      "\n",
      "53 bottles 在啤酒墙上~~\n",
      "53 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "52 bottles 在啤酒墙上\n",
      "\n",
      "52 bottles 在啤酒墙上~~\n",
      "52 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "51 bottles 在啤酒墙上\n",
      "\n",
      "51 bottles 在啤酒墙上~~\n",
      "51 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "50 bottles 在啤酒墙上\n",
      "\n",
      "50 bottles 在啤酒墙上~~\n",
      "50 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "49 bottles 在啤酒墙上\n",
      "\n",
      "49 bottles 在啤酒墙上~~\n",
      "49 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "48 bottles 在啤酒墙上\n",
      "\n",
      "48 bottles 在啤酒墙上~~\n",
      "48 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "47 bottles 在啤酒墙上\n",
      "\n",
      "47 bottles 在啤酒墙上~~\n",
      "47 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "46 bottles 在啤酒墙上\n",
      "\n",
      "46 bottles 在啤酒墙上~~\n",
      "46 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "45 bottles 在啤酒墙上\n",
      "\n",
      "45 bottles 在啤酒墙上~~\n",
      "45 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "44 bottles 在啤酒墙上\n",
      "\n",
      "44 bottles 在啤酒墙上~~\n",
      "44 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "43 bottles 在啤酒墙上\n",
      "\n",
      "43 bottles 在啤酒墙上~~\n",
      "43 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "42 bottles 在啤酒墙上\n",
      "\n",
      "42 bottles 在啤酒墙上~~\n",
      "42 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "41 bottles 在啤酒墙上\n",
      "\n",
      "41 bottles 在啤酒墙上~~\n",
      "41 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "40 bottles 在啤酒墙上\n",
      "\n",
      "40 bottles 在啤酒墙上~~\n",
      "40 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "39 bottles 在啤酒墙上\n",
      "\n",
      "39 bottles 在啤酒墙上~~\n",
      "39 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "38 bottles 在啤酒墙上\n",
      "\n",
      "38 bottles 在啤酒墙上~~\n",
      "38 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "37 bottles 在啤酒墙上\n",
      "\n",
      "37 bottles 在啤酒墙上~~\n",
      "37 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "36 bottles 在啤酒墙上\n",
      "\n",
      "36 bottles 在啤酒墙上~~\n",
      "36 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "35 bottles 在啤酒墙上\n",
      "\n",
      "35 bottles 在啤酒墙上~~\n",
      "35 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "34 bottles 在啤酒墙上\n",
      "\n",
      "34 bottles 在啤酒墙上~~\n",
      "34 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "33 bottles 在啤酒墙上\n",
      "\n",
      "33 bottles 在啤酒墙上~~\n",
      "33 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "32 bottles 在啤酒墙上\n",
      "\n",
      "32 bottles 在啤酒墙上~~\n",
      "32 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "31 bottles 在啤酒墙上\n",
      "\n",
      "31 bottles 在啤酒墙上~~\n",
      "31 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "30 bottles 在啤酒墙上\n",
      "\n",
      "30 bottles 在啤酒墙上~~\n",
      "30 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "29 bottles 在啤酒墙上\n",
      "\n",
      "29 bottles 在啤酒墙上~~\n",
      "29 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "28 bottles 在啤酒墙上\n",
      "\n",
      "28 bottles 在啤酒墙上~~\n",
      "28 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "27 bottles 在啤酒墙上\n",
      "\n",
      "27 bottles 在啤酒墙上~~\n",
      "27 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "26 bottles 在啤酒墙上\n",
      "\n",
      "26 bottles 在啤酒墙上~~\n",
      "26 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "25 bottles 在啤酒墙上\n",
      "\n",
      "25 bottles 在啤酒墙上~~\n",
      "25 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "24 bottles 在啤酒墙上\n",
      "\n",
      "24 bottles 在啤酒墙上~~\n",
      "24 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "23 bottles 在啤酒墙上\n",
      "\n",
      "23 bottles 在啤酒墙上~~\n",
      "23 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "22 bottles 在啤酒墙上\n",
      "\n",
      "22 bottles 在啤酒墙上~~\n",
      "22 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "21 bottles 在啤酒墙上\n",
      "\n",
      "21 bottles 在啤酒墙上~~\n",
      "21 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "20 bottles 在啤酒墙上\n",
      "\n",
      "20 bottles 在啤酒墙上~~\n",
      "20 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "19 bottles 在啤酒墙上\n",
      "\n",
      "19 bottles 在啤酒墙上~~\n",
      "19 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "18 bottles 在啤酒墙上\n",
      "\n",
      "18 bottles 在啤酒墙上~~\n",
      "18 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "17 bottles 在啤酒墙上\n",
      "\n",
      "17 bottles 在啤酒墙上~~\n",
      "17 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "16 bottles 在啤酒墙上\n",
      "\n",
      "16 bottles 在啤酒墙上~~\n",
      "16 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "15 bottles 在啤酒墙上\n",
      "\n",
      "15 bottles 在啤酒墙上~~\n",
      "15 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "14 bottles 在啤酒墙上\n",
      "\n",
      "14 bottles 在啤酒墙上~~\n",
      "14 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "13 bottles 在啤酒墙上\n",
      "\n",
      "13 bottles 在啤酒墙上~~\n",
      "13 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "12 bottles 在啤酒墙上\n",
      "\n",
      "12 bottles 在啤酒墙上~~\n",
      "12 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "11 bottles 在啤酒墙上\n",
      "\n",
      "11 bottles 在啤酒墙上~~\n",
      "11 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "10 bottles 在啤酒墙上\n",
      "\n",
      "10 bottles 在啤酒墙上~~\n",
      "10 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "9 bottles 在啤酒墙上\n",
      "\n",
      "9 bottles 在啤酒墙上~~\n",
      "9 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "8 bottles 在啤酒墙上\n",
      "\n",
      "8 bottles 在啤酒墙上~~\n",
      "8 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "7 bottles 在啤酒墙上\n",
      "\n",
      "7 bottles 在啤酒墙上~~\n",
      "7 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "6 bottles 在啤酒墙上\n",
      "\n",
      "6 bottles 在啤酒墙上~~\n",
      "6 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "5 bottles 在啤酒墙上\n",
      "\n",
      "5 bottles 在啤酒墙上~~\n",
      "5 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "4 bottles 在啤酒墙上\n",
      "\n",
      "4 bottles 在啤酒墙上~~\n",
      "4 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "3 bottles 在啤酒墙上\n",
      "\n",
      "3 bottles 在啤酒墙上~~\n",
      "3 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "2 bottles 在啤酒墙上\n",
      "\n",
      "2 bottles 在啤酒墙上~~\n",
      "2 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "1 bottle 在啤酒墙上\n",
      "\n",
      "1 bottle 在啤酒墙上~~\n",
      "1 bottle 啤酒~~\n",
      "拿一瓶走~~\n",
      "只剩一瓶了，不能给你了！\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 项目3 P44\n",
    "\n",
    "word = \"bottles\"\n",
    "\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"在啤酒墙上~~\")\n",
    "    print(beer_num,word,\"啤酒~~\")\n",
    "    print(\"拿一瓶走~~\")\n",
    "    if beer_num == 1:\n",
    "        print(\"只剩一瓶了，不能给你了！\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "        print(new_num,word,\"在啤酒墙上\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "251e2d2e",
   "metadata": {},
   "source": [
    "## 课后任务：\n",
    "* 思考，什么是（seq type?）\n",
    "* 预习：  数值 ，字符串\n",
    "\n",
    ">1.Numeric Types\n",
    "\n",
    ">2.Text Sequence Type"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9204b625",
   "metadata": {},
   "source": [
    "Sequence type 是序列类型\n",
    "分为三种类型：\n",
    "\n",
    "1.list\n",
    "\n",
    "2.tuple\n",
    "\n",
    "3.range"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3111b9d7",
   "metadata": {},
   "source": [
    "数值：\n",
    "\n",
    "1.整型(Int) - 通常被称为是整型或整数，是正或负整数，不带小数点。\n",
    "\n",
    "2.长整型(long integers) - 无限大小的整数，整数最后是一个大写或小写的L。\n",
    "\n",
    "3.浮点型(floating point real values) - 浮点型由整数部分与小数部分组成，浮点型也可以使用科学计数法表示。\n",
    "\n",
    "4.复数(complex numbers) - 复数由实数部分和虚数部分构成，可以用a + bj,或者complex(a,b)表示， 复数的实部a和虚部b都是浮点型。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d3647723",
   "metadata": {},
   "source": [
    "----------------------------------------------------------------\n",
    "专门处理文本的附加序列类型 (Text Sequence Types)\n",
    "\n",
    "-----------------------------------------------------------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f116e8c6",
   "metadata": {},
   "source": [
    "字符串：\n",
    "\n",
    "字符串是 Python 中最常用的数据类型。我们可以使用引号 ( ' 或 \" ) 来创建字符串。\n",
    "\n",
    "创建字符串很简单，只要为变量分配一个值即可。\n",
    "\n",
    "Python 不支持单字符类型，单字符在 Python 中也是作为一个字符串使用。\n",
    "\n",
    "Python 访问子字符串，可以使用方括号来截取字符串。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dd8c6c84",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
